﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Max.BLL;
using Max.DTO;

namespace Max.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            
            return View(new UserLogic().GetAllUsers() );
        }

        public ActionResult ShowSingleUser(FormCollection data)
        {
            return View(new UserLogic().GetUserByUserId(int.Parse(data["user_id_form"])));
        }

        [HttpPost]
        public ActionResult Add(FormCollection data)
        {
            new UserLogic().UserAdd(new UserDTO() { 
                user_name = data["user_name_form"],
                user_password = data["user_password_form"],
                user_email = data["user_email_form"],
                modify_by_user = 1,
                user_modify_date = DateTime.Now
            });

            return View();
        }

     //   [HttpPost]
        public ActionResult UpdateUserInfo(FormCollection data)
        {
            new UserLogic().UserAdd(new UserDTO()
            {
                user_name = data["user_name_form"],
                user_password = data["user_password_form"],
                user_email = data["user_email_form"],
                modify_by_user = 1,
                user_modify_date = DateTime.Now
            });

            return View();
        }

        /*
        [HttpPost]
        public ActionResult UpdateUserInfo(FormCollection data)
        {
            new UserLogic().UserAdd(new UserDTO()
            {
                user_name = data["user_name_form"],
                user_password = data["user_password_form"],
                user_email = data["user_email_form"],
                modify_by_user = 1,
                user_modify_date = DateTime.Now
            });

            return View();
        }
         */

    }
}
